<a href='https://github.com/angular/angular.js/edit/v1.4.x/src/ngMessageFormat/messageFormatService.js?message=docs($$messageFormat)%3A%20describe%20your%20change...#L12' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a>



<a href='https://github.com/angular/angular.js/tree/v1.4.7/src/ngMessageFormat/messageFormatService.js#L12' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">$$messageFormat</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
  

    <li>
      - service in module <a href="api/ngMessageFormat">ngMessageFormat</a>
    </li>
  </ol>
</header>



<div class="api-profile-description">
  <p>Angular internal service to recognize MessageFormat extensions in interpolation expressions.
For more information, see:
<a href="https://docs.google.com/a/google.com/document/d/1pbtW2yvtmFBikfRrJd8VAsabiFkKezmYZ_PbgdjQOVU/edit">https://docs.google.com/a/google.com/document/d/1pbtW2yvtmFBikfRrJd8VAsabiFkKezmYZ_PbgdjQOVU/edit</a></p>
<h2 id="example">Example</h2>
<p>

<div>
  <a ng-click="openPlunkr('examples/example-ngMessageFormat-example', $event)" class="btn pull-right">
    <i class="glyphicon glyphicon-edit">&nbsp;</i>
    Edit in Plunker</a>

  <div class="runnable-example"
      path="examples/example-ngMessageFormat-example"
      name="ngMessageFormat-example"
      module="msgFmtExample"
      deps="angular-message-format.min.js">

  
    <div class="runnable-example-file" 
      name="index.html"
      language="html"
      type="html">
      <pre><code>&lt;div ng-controller=&quot;AppController&quot;&gt;&#10;  &lt;button ng-click=&quot;decreaseRecipients()&quot; id=&quot;decreaseRecipients&quot;&gt;decreaseRecipients&lt;/button&gt;&lt;br&gt;&#10;  &lt;span&gt;{{recipients.length, plural, offset:1&#10;          =0    {{{sender.name}} gave no gifts (\#=#)}&#10;          =1    {{{sender.name}} gave one gift to {{recipients[0].name}} (\#=#)}&#10;          one   {{{sender.name}} gave {{recipients[0].name}} and one other person a gift (\#=#)}&#10;          other {{{sender.name}} gave {{recipients[0].name}} and # other people a gift (\#=#)}&#10;        }}&lt;/span&gt;&#10;&lt;/div&gt;</code></pre>
    </div>
  
    <div class="runnable-example-file" 
      name="script.js"
      language="js"
      type="js">
      <pre><code>function Person(name, gender) {&#10;  this.name = name;&#10;  this.gender = gender;&#10;}&#10;&#10;var alice   = new Person(&quot;Alice&quot;, &quot;female&quot;),&#10;    bob     = new Person(&quot;Bob&quot;, &quot;male&quot;),&#10;    charlie = new Person(&quot;Charlie&quot;, &quot;male&quot;),&#10;    harry   = new Person(&quot;Harry Potter&quot;, &quot;male&quot;);&#10;&#10;angular.module(&#39;msgFmtExample&#39;, [&#39;ngMessageFormat&#39;])&#10;  .controller(&#39;AppController&#39;, [&#39;$scope&#39;, function($scope) {&#10;      $scope.recipients = [alice, bob, charlie];&#10;      $scope.sender = harry;&#10;      $scope.decreaseRecipients = function() {&#10;        --$scope.recipients.length;&#10;      };&#10;    }]);</code></pre>
    </div>
  
    <div class="runnable-example-file" 
      name="protractor.js"
      type="protractor"
      language="js">
      <pre><code>describe(&#39;MessageFormat plural&#39;, function() {&#10;  it(&#39;should pluralize initial values&#39;, function() {&#10;    var messageElem = element(by.binding(&#39;recipients.length&#39;)), decreaseRecipientsBtn = element(by.id(&#39;decreaseRecipients&#39;));&#10;    expect(messageElem.getText()).toEqual(&#39;Harry Potter gave Alice and 2 other people a gift (#=2)&#39;);&#10;    decreaseRecipientsBtn.click();&#10;    expect(messageElem.getText()).toEqual(&#39;Harry Potter gave Alice and one other person a gift (#=1)&#39;);&#10;    decreaseRecipientsBtn.click();&#10;    expect(messageElem.getText()).toEqual(&#39;Harry Potter gave one gift to Alice (#=0)&#39;);&#10;    decreaseRecipientsBtn.click();&#10;    expect(messageElem.getText()).toEqual(&#39;Harry Potter gave no gifts (#=-1)&#39;);&#10;  });&#10;});</code></pre>
    </div>
  

    <iframe class="runnable-example-frame" src="examples/example-ngMessageFormat-example/index.html" name="example-ngMessageFormat-example"></iframe>
  </div>
</div>


</p>

</div>




<div>
  

    

  

  
  
  



  
</div>


